package com.shuma.product.config;

import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.stp.StpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class SaTokenPermission implements StpInterface {

    private static final Logger LOG = LoggerFactory.getLogger(SaTokenPermission.class);

    @Autowired
    private RedisTemplate redisTemplate;


    @Override
    public List<String> getPermissionList(Object o, String s) {
        return null;
    }

    // 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验)
    @Override
    public List<String> getRoleList(Object loginId, String loginType) {

        List<String> list = new ArrayList<>();
        String role = (String) redisTemplate.opsForValue().get(StpUtil.getLoginId());
        list.add(role);

        return list;
    }
}
